﻿function Get-TSMNodeOccupancy {    
    <#
        .SYNOPSIS
            Get TSM node occupancy
                    
        .DESCRIPTION
            The Get-TSMNodeOccupancy returns node occupancy

        .PARAMETER Node
            The node to search

        .EXAMPLE
            Get-TSMNodeOccupancy

        .NOTES
            Contributors:  David Seibel
            Last Revision Date: 09/01/2015

    #>
    [CmdletBinding()]
    Param(
        [Parameter(Position=0)]
        $Node
    )
    
    $whereProps = @()
    $whereProps += [PSCustomObject]@{ "Column" = "NODE_NAME";   "Operator" = "LIKE"; "Value" = $Node }

    $query = Format-TSMQuery -Table "OCCUPANCY" -Where $whereProps -OrderBy "NODE_NAME"
    $result = Invoke-TSMCommand -Command $query
    
    $defaultDisplaySet = 'NODE_NAME','FILESPACE_NAME','NUM_FILES','LOGICAL_MB'
    $typeDefinitions = @{
                        "NUM_FILES"    =[Int32]
                        "PHYSICAL_MB"  =[Double]
                        "LOGICAL_MB"   =[Double]
                        "REPORTING_MB" =[Double]
                        }

    return Format-TSMData -Data $result -TypeDefinitions $typeDefinitions -DefaultDisplaySet $defaultDisplaySet
}